# 申购单详情页
from time import sleep

from dim_web_auto_test.page.login_page.login_page import LoginPage
from setting import *
from tools.get_future_day import get_future_date


class PurchaseApplyDetailPage(LoginPage):
    def goto_pc_apply_detail_page_by_url(self, order_no="206-PR2112210001"):
        """
        通过链接方式打开对应申购单的详情页
        :param order_no:
        :return:
        """
        self.goto_page_by_url(SIT_SCM_APPLY_PURCHASE_DETAIL_URL.format(order_no))

    def copy_purchase_apply(self):
        """
        复制申购单
        :return:
        """
        self.click("pc_apply_detail_page.more_btn")
        self.click("pc_apply_detail_page.copy_btn")

    def create_and_save_purchase_apply(self):
        """
        创建并提交申购单
        :return:
        """
        self.send_keys("pc_apply_detail_page.arrival_day_input", get_future_date(10))
        self.click("pc_apply_detail_page.confirm_btn")
        self.click("pc_apply_detail_page.commit_btn")
